// 网格线
export const Canvas = {
    drawGrid(canvasId, color, stepx, stepy) {
        let canvas = document.getElementById(canvasId);
        let context = canvas.getContext('2d');
        context.save()
        context.fillStyle = 'rgba(255, 255, 255, 0)';
        context.fillRect(0, 0, context.canvas.width, context.canvas.height);
        context.lineWidth = 0.5;
        context.strokeStyle = color;
        for (let i = 0; i <= context.canvas.width; i += stepx) {
            context.beginPath();
            context.moveTo(i, 0);
            context.lineTo(i, context.canvas.height);
            context.closePath();
            context.stroke();
        }
        for (let j = 0; j <= context.canvas.height; j += stepy) {
            context.beginPath();
            context.moveTo(0, j);
            context.lineTo(context.canvas.width, j);
            context.closePath();
            context.stroke();
        }
        context.restore();
    }
}